home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Hacking & Misc / bundle of exploits.sit / bundle of exploits / makedir.txt < prev    next >
Text File  |  1998-07-17  |  3KB  |  101 lines

  1.  
  2. ------SNIP(makedir.c)--------START
  3. /* makedir.c v1.0 A fun toy by Nathan D. Faber (Drago)        *
  4.  * Drago@Drago.com || root@very.cheap.org            *
  5.  * Written to show a problem with long deep/long directorys.    *
  6.  * !WARNING!: Don't use random unless you know what your doing    *
  7.  * and can figure out how to get rid of the directorys. (play    *
  8.  * around with debugfs)                        *
  9.  * ------------------------------------------------------------ *
  10.  *      This is a shitload of crappy code, Enjoy!        */
  11.  
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include <sys/types.h>
  15. #include <fcntl.h>
  16. #include <unistd.h>
  17. #include <sys/stat.h>
  18. #include <time.h>
  19.  
  20. #define DEFAULT_PERM 448
  21.  
  22. /*#define CHANGE_PERM*/
  23.  
  24. #define RANDOM_NAMES
  25.  
  26. /* Need to be uid/grp 0 for this to work (??)*/
  27. #define UID_GRP_CHANGE 0
  28. #define GRP_NUMB 911
  29. #define USR_NUMB 911
  30.  
  31. /*Sloppy code begins here*/
  32. main(int argc, char *argv[]){
  33. char * dnames[20] = {"bust muh nuts.","leet","feer cheese wiz","spank dat whore",
  34. "weeny","blah", "chewme","Ping Pong Bong","ha!",
  35. "I am yer god so yew must feer!", "Please note that I am your owner!",
  36. "~!@#$%^&*()_+","Fucking A!?!?!?!", "Doobie doobie doo, and uhh, beware of the penguins.",
  37. "The penguin is your friend!", "Buckle up, its the law","Dead on arrival",
  38. "Eat shit and die fuxer!","............................",
  39. "You can pick your friends, you can pick your nose, but you cant pick your friends nose."};
  40. int i;
  41. char named[100];
  42. srand(time(NULL)); /*Seed rand, could of used time.h to seed this, but why bother, this works ok*/
  43. if ((argc!=3)&&(argc!=4)){printf("Usage: %s <Dir to make> <Times> [Rand]\n",argv[0]);exit(0);}
  44. for (i=0;i!=atoi(argv[2]);i++){
  45.     /*Rand handling*/
  46.     if(!i){mkdir(argv[1],DEFAULT_PERM);chdir(argv[1]);continue;}
  47.     if(argc>3){
  48. #ifdef RANDOM_NAMES
  49.     sprintf(named,"%s",dnames[rand()%20]);}
  50. #else
  51.     sprintf(named,"%i",rand());} /*I *REALLY* do suck at handling integers :)*/
  52. #endif
  53.     /*Standard handling*/
  54.     else{
  55.         sprintf(named,"%s",argv[1]);}
  56.     mkdir(named,DEFAULT_PERM);
  57.     chdir(named);}
  58. /*Set permissions if we are not using rand.  Do we really need to set
  59. these? gives you more hell if your the user deleting them and uid/gid!=0*/
  60. #ifdef CHANGE_PERM
  61. for (i=0;i<atoi(argv[2]);i++){
  62.         if(!i){if(argc>3){printf("Skiping persmission flush due to rand.\n");break;}
  63.         else{printf("Setting permissions on %i directorys (0000).\n",atoi(argv[2]));}}
  64.         chdir("..");
  65.         if (UID_GRP_CHANGE)
  66.         {chown(argv[1],USR_NUMB,GRP_NUMB);}
  67.         chmod(argv[1],00000);
  68.     }
  69. #endif
  70. printf("Done. %d directorys created recursivly (%s).\n",atoi(argv[2]),argv[1]);
  71. }
  72. /*EOF*/
  73. ------SNIP(makedir.c)--------END
  74.  
  75.  
  76.  
  77. ------SNIP(killdir.c)--------START
  78. /* killdir.c By Nathan D. Faber (Drago)                *
  79.  * Drago@Drago.com || root@very.cheap.org            *
  80.  * Used to terminate deep directorys that contain the same name.*/
  81.  
  82. #include <stdio.h>
  83. #include <stdlib.h>
  84. #include <sys/types.h>
  85. #include <sys/stat.h>
  86. main(int argc, char * argv[])    {
  87. int i,x;
  88. char * name=argv[1];
  89. if (argc!=2){printf("Usage: %s <Name of recursive dir>\n",argv[0]);exit(0);}
  90. for (i=0;i!=-1;i++){
  91.     if (chdir(name)!=0){
  92.         chdir("..");
  93.         x=rmdir(name);
  94.         printf("R %i : %s\n",i,(x==0)?"Ok":"Bad");
  95.         if (x!=0){printf("Deleted %i dirs named %s.\n",(i/2),argv[1]);break;}
  96.         }
  97.     }
  98. }
  99. /*EOF*/
  100. ------SNIP(killdir.c)--------START
  101.